namespace my_map
{
	template<class K, class V>
	class map
	{
		struct KeyOfMap
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename RBTree<K, pair<K, V>, KeyOfMap>::iterator iterator;
		typedef typename RBTree<K, pair<K, V>, KeyOfMap>::const_iterator const_iterator;

		iterator begin() { return _tree.begin(); }
		const_iterator begin() const { return _tree.begin(); }
		iterator end() { return _tree.end(); }
		const_iterator end() const { return _tree.end(); }

		pair<iterator, bool> insert(const pair<K, V>& kv) { return _tree.insert(kv); }
		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = insert(make_pair(key, V()));
			return (ret.first)->second;
		}
		iterator find(const K& k) { return _tree.find(k); }

	private:
		RBTree<K, pair<K, V>, KeyOfMap> _tree;
	};
}
